package ReferencePrimaryHalConfigBuild

import (
        "android/soong/android"
         "android/soong/cc"
         "fmt"
)

func init() {
    fmt.Println("AHAL go init start")
    android.RegisterModuleType("ahal_go_config_build_default", AHALDefaultsFactory)
}

func AHALDefaultsFactory() (android.Module) {
    module := cc.DefaultsFactory()
    android.AddLoadHook(module, AddAHALConfig)
    return module
}

func AddAHALConfig(ctx android.LoadHookContext) {
    type props struct {
        Shared_libs []string
        Cflags []string
    }
    p := &props{} 
    p.Cflags = addFlags(ctx)
    ctx.AppendProperties(p)
}


func addFlags(ctx android.BaseContext) ([]string) {
    var cppflags []string
    product := ctx.AConfig().Getenv("TARGET_PRODUCT");
    fmt.Println("TARGET_PRODUCT: ", product)

    if product == "msmnile_gvmq"{
        cppflags = append(cppflags, "-DPRODUC_MSMNILE_GVMQ")
    } else if product == "gen4"{
        cppflags = append(cppflags, "-DPRODUCT_GEN4")
    } else {
        fmt.Println("product is null")
        cppflags = append(cppflags, "-DPRODUC_MSMNILE_GVMQ")
    }
    return cppflags;
}

